﻿@using ZoomLa.AppCode.Controls
@model ZoomLa.Model.M_Exam_Sys_Papers
@{
    SelectList rtypelist = MVCHelper.ToSelectList("自动阅卷,手工阅卷".Split(','), "1,2".Split(','), "1");
    SelectList typelist = MVCHelper.ToSelectList("固定试卷(手工),固定试卷(随机),随机试卷".Split(','), "1,2,3".Split(','), "1");
    if (Model.id < 1) { Model.p_endTime = DateTime.Now.AddMonths(6); }
}
@section head{
    <title>试卷管理</title>
    <script type="text/javascript" src="/JS/OAKeyWord.js"></script>
}
@section content{
<div class="container-fluid mysite" id="BreadDiv">
    <div class="row">
        <ol id="BreadNav" class="breadcrumb navbar-fixed-top">
            <li><a href='@(CustomerPageAction.customPath2)I/Main.aspx'>工作台</a></li>
            <li><a href='Papers_System_Manage'>教育模块</a></li>
            <li><a href='Papers_System_Manage'>试卷管理</a></li>
            <li>@ViewBag.title</li>
        </ol>
    </div>
</div>
    <form method="post" action="@MVCHelper.GetAction("Papers_Add",Request)">
    <table class="table table-striped table-bordered table-hover" style="margin-bottom:61px;">
        <tr>
            <td class="td_l">试卷名称：</td>
            <td class="bqright">
                <input type="text" id="p_name" name="p_name" value="@Model.p_name" class="form-control text_300" />
            </td>
        </tr>
        <tr>
            <td>阅卷类型：</td>
            <td class="bqright">
                @Html.DropDownListFor(m => m.p_rtype, rtypelist, new { @class = "form-control text_300" })
            </td>
        </tr>
        <tr>
            <td>出题方式：</td>
            <td class="bqright">
                @Html.DropDownListFor(m => m.p_type, typelist, new { @class = "form-control text_300" })
            </td>
        </tr>
        <tr>
            <td>所属科目：</td>
            <td>
                @Html.Partial("C_TreeTlpDP", (C_TreeTlpDP)ViewBag.treeMod)
            </td>
        </tr>
        <tr>
            <td>关键字：</td>
            <td>
                <div id="Examkeyword"></div>
                <input type="text" id="TagKey" name="TagKey" value="@Model.TagKey" class="form-control text_300" style="display:none;" />
                <button type="button" onclick="ShowKeyWords()" class="btn btn-primary btn-sm">选择关键字</button>
                <span class="rd_green">(使用空格键或回车键分隔关键字，每个关键字长度不超过5个)</span>
            </td>
        </tr>
        <tr>
            <td>
                考试时间：
            </td>
            <td class="bqright">
                <input type="text" id="p_UseTime" name="p_UseTime" value="@Model.p_UseTime" class="form-control text_300" /><span>分钟</span>
                <span class="rd_green">(为0不限时间,否则到时自动提交)</span>
            </td>
        </tr>
        <tr>
            <td>有效时间：</td>
            <td>
                <input type="text" id="p_BeginTime" name="p_BeginTime" value="@Model.p_BeginTime.ToString("yyyy/MM/dd HH:mm")" onclick="WdatePicker({ maxDate: '#F{$dp.$D(\'p_endTime\')}', dateFmt: 'yyyy/MM/dd HH:mm' });" placeholder="起始时间" class="form-control text_md" />
                <span>至</span>
                <input type="text" id="p_endTime" name="p_endTime" value="@Model.p_endTime.ToString("yyyy/MM/dd HH:mm")" onclick="WdatePicker({ minDate: '#F{$dp.$D(\'p_BeginTime\')}', dateFmt: 'yyyy/MM/dd HH:mm' });" placeholder="结束时间" class="form-control text_md" />
                <span class="rd_green">为空则不限定时间</span>
            </td>
        </tr>
        <tr>
            <td>
                说明：
            </td>
            <td>
                <textarea id="p_Remark" name="p_Remark" class="form-control m715-50" style="height:80px">@Model.p_Remark</textarea>
            </td>
        </tr>
    </table>
    <div class="text-center Conent_fix">
        <button type="submit" class="btn btn-primary">保存试卷</button>
        <a href="Papers_System_Manage" class="btn btn-primary">返回列表</a>
    </div>
</form>
}
@section script{
    <style type="text/css">
        #option_ul li { margin-top: 3px; }
        .tabinput { border: none; padding-left: 5px; height: 30px; line-height: 30px; }
        .radius { margin: 2px; margin-top: 20px; height: 24px; line-height: 24px; background: #eee; border: 1px solid #ddd; border-radius: 3px; padding: 3px; float: none !important; }
        #errormes { z-index: 9999; }
    </style>
    <script src="/JS/Controls/ZL_Dialog.js"></script>
    <script type="text/javascript" src="/JS/DatePicker/WdatePicker.js"></script>
    <script>
        var tabarr = [];
        $(function () {
            InitKeyWord($("#TagKey").val());
            $("form").validate({
                rules: {
                    p_name: { required: true }
                },
                messages: {
                    p_name: { required: "试卷名称不能为空" }
                },
            })
        });
        function InitKeyWord(value) {
            tabarr = [];
            $("#Examkeyword").html('');
            if ($("#Examkeyword").length > 0) {
                $("#Examkeyword").tabControl({
                    maxTabCount: 5,
                    tabW: 80,
                    onAddTab: function (value) {
                        tabarr.push(value);
                        console.log(tabarr);
                    },
                    onRemoveTab: function (removeval) {
                        for (var i = 0; i < tabarr.length; i++) {
                            if (tabarr[i] == removeval) {
                                tabarr.splice(i, 1);
                                break;
                            }
                        }
                    }
                }, value);
            }//关键词
        }
        function ShowKeyWords() {
            comdiag.reload = true;
            comdiag.maxbtn = false;
            comdiag.width = "none";
            ShowComDiag("/Common/SelKeyWords.aspx?type=3", "选择关键字");
        }
        function GetKeyWords(keystr) {
            tabarr = tabarr.concat(keystr.split(','));
            var values = "";
            var length = tabarr.length <= 5 ? tabarr.length : 5;
            for (var i = 0; i < length; i++) {
                if (IsDis(values, tabarr[i]))
                { values += tabarr[i] + ","; }
            }
            InitKeyWord(values);
            CloseComDiag();
        }
        //判断重复
        function IsDis(arrstr, value) {
            for (var i = 0; i < tabarr.length; i++) {
                if (("," + arrstr).indexOf("," + value + ",") > -1) {
                    return false;
                }
            }
            return true;
        }
    </script>
}